<!DOCTYPE HTML>
<html lang="en">
<head>
<title>WinMove - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The WinMove command changes the position and/or size of the specified window." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>WinMove</h1>

<p>Changes the position and/or size of the specified window.</p>

<pre class="Syntax">
<span class="func">WinMove</span>, X, Y
<span class="func">WinMove</span>, WinTitle, WinText, X, Y <span class="optional">, Width, Height, ExcludeTitle, ExcludeText</span>
</pre>
<h2>Parameters</h2>
<dl>

  <dt>X, Y</dt>
  <dd><p>The X and Y coordinates (in pixels) of the upper left corner of the target window's new location, which can be <a href="../Variables.htm#Expressions">expressions</a>. The upper-left pixel of the screen is at 0, 0.</p>
    <p>If these are the only parameters given with the command, the <a href="../misc/WinTitle.htm#LastFoundWindow">Last Found Window</a> will be used as the target window.</p>
    <p>Otherwise, X and/or Y can be omitted, in which case the current position is used.</p></dd>

  <dt>WinTitle</dt>
  <dd><p>A window title or other criteria identifying the target window. See <a href="../misc/WinTitle.htm">WinTitle</a>. See also the <a href="#limitation">known limitation</a> below.</p></dd>

  <dt>WinText</dt>
  <dd><p>If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if <a href="DetectHiddenText.htm">DetectHiddenText</a> is ON. See also the <a href="#limitation">known limitation</a> below.</p></dd>

  <dt>Width, Height</dt>
  <dd><p>The new width and height of the window (in pixels), which can be <a href="../Variables.htm#Expressions">expressions</a>. If either is omitted, blank, or the word DEFAULT, the size in that dimension will not be changed.</p></dd>

  <dt>ExcludeTitle</dt>
  <dd><p>Windows whose titles include this value will not be considered.</p></dd>

  <dt>ExcludeText</dt>
  <dd><p>Windows whose text include this value will not be considered.</p></dd>

</dl>

<h2>Remarks</h2>
<p>If <em>Width</em> and <em>Height</em> are small (or negative), most windows with a title bar will generally go no smaller than 112 x 27 pixels (however, some types of windows may have a different minimum size). If <em>Width</em> and <em>Height</em> are large, most windows will go no larger than approximately 12 pixels beyond the dimensions of the desktop.</p>
<p>Negative values are allowed for the x and y coordinates to support multi-monitor systems and to allow a window to be moved entirely off screen.</p>
<p>Although WinMove cannot move minimized windows, it can move hidden windows if <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> is on.</p>
<p>The speed of WinMove is affected by <a href="SetWinDelay.htm">SetWinDelay</a>.</p>
<p>Window titles and text are case sensitive. Hidden windows are not detected unless <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> has been turned on.</p>
<p id="limitation"><strong>Known limitation</strong>: If <em>WinTitle</em> or <em>WinText</em> contains <code>(</code>, <code>[</code> or <code>{</code>, but not the closing counterpart, such as <code>WinMove, KEDIT - [</code>, the parameter is automatically interpreted as an <a href="../Variables.htm#Expressions">expression</a>, resulting in an error message. To avoid this, you can use a <a href="../Variables.htm#percent-space">leading percent sign</a> to force a literal string instead, such as <code>WinMove, % "KEDIT - ["</code>.</p>
<h2>Related</h2>
<p><a href="ControlMove.htm">ControlMove</a>, <a href="WinGetPos.htm">WinGetPos</a>, <a href="WinHide.htm">WinHide</a>, <a href="WinMinimize.htm">WinMinimize</a>, <a href="WinMaximize.htm">WinMaximize</a>, <a href="WinSet.htm">WinSet</a></p>
<h2>Examples</h2>
<div class="ex" id="ExLastFound">
<p><a href="#ExLastFound">#1</a></p>
<pre>Run, calc.exe
WinWait, Calculator
WinMove, 0, 0 <em>; Move the window found by WinWait to the upper-left corner of the screen.</em></pre>
</div>

<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#2</a></p>
<pre>SplashTextOn, 400, 300, Clipboard, The clipboard contains:`n%clipboard%
WinMove, Clipboard, , 0, 0 <em>; Move the splash window to the top left corner.</em>
MsgBox, Press OK to dismiss the SplashText
SplashTextOff</pre>
</div>

<div class="ex" id="ExCenter">
<p><a href="#ExCenter">#3</a>: The following <a href="../Functions.htm">function</a> centers the specified window on the screen:</p>
<pre>CenterWindow(WinTitle)
{
    WinGetPos,,, Width, Height, %WinTitle%
    WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
}</pre>
</div>

</body>
</html>
